﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.Practices.Unity;
using ePlanet.ArchiveMange.Services;
using ePlanet.ArchiveMange.Enum;
using DreamBuilder.Core.Container;
using ePlanet.ArchiveMange.Models;
using Web.SystemConfig.Services;

namespace Web.Views.ArchiveManage
{
    public partial class ArchiveViewPage : PageBase
    {
        #region 属性
        /// <summary>
        /// 文档类型ID
        /// </summary>
        public int ArchiveTypeID
        {
            get
            {
                int o_int = 0;
                if (Request.QueryString["archivetype"] != null)
                {
                    if (int.TryParse(Request.QueryString["archivetype"], out o_int))
                    {
                        return o_int;
                    }
                    else
                    {
                        throw new Exception("档案类型错误");
                    }
                }
                else
                {
                    throw new Exception("档案类型不能为空");
                }
            }
        }

        [Dependency]
        public IArchiveMenuService ArchiveMenuService
        {
            get;
            set;
        }
        #endregion


       protected void Page_Load(object sender, EventArgs e)
       {
           if (!IsPostBack)
           {
               this.archiveTypeId.Value = this.ArchiveTypeID.ToString();
               if (ArchiveTypeID == 0)
                   return;
               string urlFormat = "../SystemLogin/loadingpage.aspx?Menu_URL=../ArchiveManage/{0}?archiveType={1}";
               int baseTypeId = ArchiveMenuService.GetArchiveBaseIDById(ArchiveTypeID);
               switch (baseTypeId)
               {
                   //文书类
                   case ((int)ArchiveBaseType.Document):
                       this.Response.Redirect(string.Format(urlFormat, "DocumentArchiveList.aspx", ArchiveTypeID));
                       break;
                   //会计类
                   case ((int)ArchiveBaseType.Account):
                       this.Response.Redirect(string.Format(urlFormat, "AccountArchiveList.aspx", ArchiveTypeID));
                       break;
                   //基建类
                   case ((int)ArchiveBaseType.BulidProject):
                       this.Response.Redirect(string.Format(urlFormat, "BuildProjectArchiveList.aspx", ArchiveTypeID));
                       break;
                   //设备类
                   case ((int)ArchiveBaseType.Equipment):
                       this.Response.Redirect(string.Format(urlFormat, "EquipArchiveList.aspx", ArchiveTypeID));
                       break;
                       //油气勘探类
                    case ((int)ArchiveBaseType.OliSearch):
                       this.Response.Redirect(string.Format(urlFormat, "OliSearchArchiveList.aspx", ArchiveTypeID));
                       break;
                    //音像类
                    case ((int)ArchiveBaseType.AudioVedio):
                       this.Response.Redirect(string.Format(urlFormat, "AudioArchiveList.aspx", ArchiveTypeID));
                       break;
                    //实物类
                    case ((int)ArchiveBaseType.RealKind):
                       this.Response.Redirect(string.Format(urlFormat, "RealKindArchiveList.aspx", ArchiveTypeID));
                       break;
                    //科研类
                    case ((int)ArchiveBaseType.Technology):
                       this.Response.Redirect(string.Format(urlFormat, "TechArchiveList.aspx", ArchiveTypeID));
                       break;
                    //光盘类
                    case ((int)ArchiveBaseType.CDKind):
                       this.Response.Redirect(string.Format(urlFormat, "CDArchiveList.aspx", ArchiveTypeID));
                       break;
               }
           }
       }

    }
}